//
//  AddCardTableViewCell.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/19.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "AddCardTableViewCell.h"

@interface AddCardTableViewCell ()

@property (nonatomic, strong)UILabel * nameLabel;

@property (nonatomic, strong)UIView * lineView;


@end

@implementation AddCardTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.backgroundColor = [UIColor clearColor];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    
    self.nameLabel = [UILabel new];
    
    self.nameLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size:16 * SCREENH6];
    self.nameLabel.textColor = ColorWithRGB(0xffffff);
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.nameLabel.text = @"已绑定银行卡";
    
    [self addSubview:self.nameLabel];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
    
    
    self.moneyLabel = [UILabel new];
    
    self.moneyLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:15 * SCREENH6];
    self.moneyLabel.textColor = ColorWithRGB(0xd5d5d5);
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    
    [self addSubview:self.moneyLabel];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.trailing.mas_equalTo(self).offset(-30 * SCREENH6);
    }];
    
    self.lineView = [UIView new];
    
    self.lineView.backgroundColor = [UIColor whiteColor];
    self.lineView.alpha = 0.1;
    
    [self addSubview:self.lineView];
    
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.trailing.bottom.mas_equalTo(self);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
    
}

-(void)setModel:(AddBankCardModel *)model{
    _model = model;
    
    NSString * bankNo = model.bankNo;
    NSString * bankName = model.bankName;
    
    NSString * bankInfo;
    
    if (bankNo.length == 19) {
        
        NSString * bankNum = [bankNo substringFromIndex:15];
        
        bankInfo = [NSString stringWithFormat:@"%@(尾号%@)",bankName,bankNum];
        
    }else{
        NSString * bankNum = [bankNo substringFromIndex:12];
        
        bankInfo = [NSString stringWithFormat:@"%@(尾号%@)",bankName,bankNum];
        
    }
    
    self.moneyLabel.text = bankInfo;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
